home *** CD-ROM | disk | FTP | other *** search
- package mx.controls
- {
- import flash.display.DisplayObject;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- import mx.core.EdgeMetrics;
- import mx.core.IFlexDisplayObject;
- import mx.core.IToolTip;
- import mx.core.UIComponent;
- import mx.core.UITextField;
- import mx.core.mx_internal;
- import mx.skins.RectangularBorder;
- import mx.styles.ISimpleStyleClient;
-
- use namespace mx_internal;
-
- public class ToolTip extends UIComponent implements IToolTip
- {
- mx_internal static const VERSION:String = "2.0.1.0";
-
- public static var maxWidth:Number = 300;
-
- mx_internal var border:IFlexDisplayObject;
-
- private var textChanged:Boolean;
-
- private var _text:String;
-
- protected var textField:UITextField;
-
- public function ToolTip()
- {
- super();
- mouseEnabled = false;
- }
-
- mx_internal function getTextField() : UITextField
- {
- return textField;
- }
-
- public function get text() : String
- {
- return _text;
- }
-
- override protected function measure() : void
- {
- var _loc1_:EdgeMetrics = null;
- var _loc2_:Number = NaN;
- var _loc3_:Number = NaN;
- var _loc4_:Number = NaN;
- var _loc5_:Number = NaN;
- var _loc6_:Number = NaN;
- var _loc7_:Number = NaN;
- super.measure();
- _loc1_ = borderMetrics;
- _loc2_ = _loc1_.left + getStyle("paddingLeft");
- _loc3_ = _loc1_.top + getStyle("paddingTop");
- _loc4_ = _loc1_.right + getStyle("paddingRight");
- _loc5_ = _loc1_.bottom + getStyle("paddingBottom");
- _loc6_ = _loc2_ + _loc4_;
- _loc7_ = _loc3_ + _loc5_;
- textField.wordWrap = false;
- if(textField.textWidth + _loc6_ > ToolTip.maxWidth)
- {
- textField.width = ToolTip.maxWidth - _loc6_;
- textField.wordWrap = true;
- }
- measuredWidth = textField.width + _loc6_;
- measuredHeight = textField.height + _loc7_;
- }
-
- override protected function commitProperties() : void
- {
- var _loc1_:TextFormat = null;
- super.commitProperties();
- if(textChanged)
- {
- _loc1_ = textField.getTextFormat();
- _loc1_.leftMargin = 0;
- _loc1_.rightMargin = 0;
- textField.defaultTextFormat = _loc1_;
- textField.text = _text;
- textChanged = false;
- }
- }
-
- public function set text(param1:String) : void
- {
- _text = param1;
- textChanged = true;
- invalidateProperties();
- invalidateSize();
- invalidateDisplayList();
- }
-
- override protected function createChildren() : void
- {
- var _loc1_:Class = null;
- super.createChildren();
- if(!mx_internal::border)
- {
- _loc1_ = getStyle("borderSkin");
- mx_internal::border = new _loc1_();
- if(mx_internal::border is ISimpleStyleClient)
- {
- ISimpleStyleClient(mx_internal::border).styleName = this;
- }
- addChild(DisplayObject(mx_internal::border));
- }
- if(!textField)
- {
- textField = new UITextField();
- textField.autoSize = TextFieldAutoSize.LEFT;
- textField.mouseEnabled = false;
- textField.multiline = true;
- textField.selectable = false;
- textField.wordWrap = false;
- textField.styleName = this;
- addChild(textField);
- }
- }
-
- private function get borderMetrics() : EdgeMetrics
- {
- if(mx_internal::border is RectangularBorder)
- {
- return RectangularBorder(mx_internal::border).borderMetrics;
- }
- return EdgeMetrics.EMPTY;
- }
-
- override public function styleChanged(param1:String) : void
- {
- super.styleChanged(param1);
- if(param1 == "borderStyle" || param1 == "styleName" || param1 == null)
- {
- invalidateDisplayList();
- }
- }
-
- override protected function updateDisplayList(param1:Number, param2:Number) : void
- {
- var _loc3_:EdgeMetrics = null;
- var _loc4_:Number = NaN;
- var _loc5_:Number = NaN;
- var _loc6_:Number = NaN;
- var _loc7_:Number = NaN;
- var _loc8_:Number = NaN;
- var _loc9_:Number = NaN;
- super.updateDisplayList(param1,param2);
- _loc3_ = borderMetrics;
- _loc4_ = _loc3_.left + getStyle("paddingLeft");
- _loc5_ = _loc3_.top + getStyle("paddingTop");
- _loc6_ = _loc3_.right + getStyle("paddingRight");
- _loc7_ = _loc3_.bottom + getStyle("paddingBottom");
- _loc8_ = _loc4_ + _loc6_;
- _loc9_ = _loc5_ + _loc7_;
- mx_internal::border.setActualSize(param1,param2);
- textField.move(_loc4_,_loc5_);
- textField.setActualSize(param1 - _loc8_,param2 - _loc9_);
- }
- }
- }
-
-